package com.goktech.olala.server.dao.goods;

import com.goktech.olala.core.req.ReqBusiness;
import com.goktech.olala.core.resp.RespBusinessVo;
import com.goktech.olala.server.pojo.goods.Business;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BusinessMapper {
    int deleteByPrimaryKey(String businessId);

    int insert(Business business);

    Business selectByPrimaryKey(String businessId);

    List<Business> selectAll();

    int updateByPrimaryKey(Business record);

    @Select("<script>" +
            "SELECT BUSINESS.BUSINESS_ID businessId, BUSINESS.BUSINESS_NAME businessName, BUSINESS.BUSINESS_CODE businessCode, BUSINESS.ADDRESS, BUSINESS.SEND_RANGE sendRange," +
            "BUSINESS.FANS_COUNT fansCount, BUSINESS.SCORE, BUSINESS.BUSINESS_LEVEL businessLevel, BUSINESS.BUSINESS_TYPE businessType, BUSINESS.TERMINAL_CODE terminalCode, BUSINESS.STATUS," +
            "BUSINESS.UPDATE_TIME updateTime, BUSINESS.UPDATE_BY updateBy " +
            "FROM G_BUSINESS BUSINESS"+
            "<where>" +
                "<if test=\"reqBusiness.businessId != null and reqBusiness.businessId != '' \">" +
                    " AND BUSINESS.BUSINESS_ID = #{reqBusiness.businessId}" +
                "</if>" +
                "<if test=\"reqBusiness.businessName != null and reqBusiness.businessName != '' \">" +
                    " AND BUSINESS.BUSINESS_NAME = '%${reqBusiness.businessName}%'" +
                "</if>" +
                "<if test=\"reqBusiness.businessType != null and reqBusiness.businessType != '' \">" +
                    " AND BUSINESS.BUSINESS_TYPE = #{reqBusiness.businessType}" +
                "</if>" +
                "<if test=\"reqBusiness.businessLevel != null and reqBusiness.businessLevel != '' \">" +
                    " AND BUSINESS.BUSINESS_LEVEL = #{reqBusiness.businessLevel}" +
                "</if>" +
            "</where>"
            +"</script>")
    List<RespBusinessVo> selectByExample(@Param("reqBusiness") ReqBusiness reqBusiness);

}